﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EdexApiClient.api.v2
{
    public partial class EdexApiContext
    {
        public async Task<CommonApiResponse<API_SESSION2>> GetSession(string email, string password)
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/login/?email={0}&password={1}");
            uri = String.Format(uri, email, password);

            return await this.GetData<API_SESSION2>(uri);
        }

        public async Task<CommonApiResponse<API_SESSION2>> GetSession(string api_key)
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/login/?api_key={0}");
            uri = String.Format(uri, api_key);

            return await this.GetData<API_SESSION2>(uri);
        }

        public async Task<CommonApiResponse> LogOut()
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/logout/?api_key={0}");
            uri = String.Format(uri, this.api_key);

            return await this.GetData(uri);
        }

        public async Task<CommonApiResponse<SEC_USERS>> GetSessionUser()
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/GetSessionUser/?api_key={0}");
            uri = String.Format(uri, this.api_key);

            return await this.GetData<SEC_USERS>(uri);
        }

        public async Task<CommonApiResponse<WH_COMPANIES>> GetSessionCompany()
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/GetSessionCompany/?api_key={0}");
            uri = String.Format(uri, this.api_key);

            return await this.GetData<WH_COMPANIES>(uri);
        }

        public async Task<CommonApiResponse> ChangeSessionCompany(Guid COMPANY_GUID)
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/ChangeCompany/?api_key={0}&COMPANY_GUID={1}");
            uri = String.Format(uri, this.api_key, COMPANY_GUID);

            return await this.GetData(uri);
        }

        public async Task<CommonApiResponse> Register(SEC_USERS user)
        {
            var uri = System.IO.Path.Combine(this.RootUri, "profile/Register/");
            return await this.Post<SEC_USERS>(uri, user);
        }


    }
}
